Skip to content

Add GFM Table Serialization Support to mdast_util_to_markdown #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jp-knj
Copy link

@jp-knj jp-knj commented Aug 6, 2025

Closes: #171

Overview

This PR implements table serialization support for the mdast_util_to_markdown crate, bringing it to feature parity with the JavaScript https://github.com/syntax-tree/mdast-util-gfm-table package. Previously, attempting to serialize ASTs containing GFM table nodes would result in an "unexpected-node" error.

Testing

Added comprehensive test coverage in tests/table.rs

  • Basic table structures
  • Column alignment variations
  • Unicode content handling
  • Pipe escaping scenarios
  • Empty cells and edge cases
  • Complex inline elements
  • Error conditions

Run tests with:

# Build with the feature
cargo build --features unicode-width

# Run tests with the feature
cargo test --features unicode-width

Uses conditional compilation to:

  • Default: Character count (.chars().count()), no dependency needed
  • With feature: Unicode display width, proper CJK/emoji alignment

@wooorm
Copy link
Owner

wooorm commented Aug 6, 2025

unicodewith seems like a step way from the upstream. And, a dependency.
Why not make it optional, configurable?

@jp-knj
Copy link
Author

jp-knj commented Aug 7, 2025

You're right, I'll do that

@jp-knj jp-knj marked this pull request as ready for review August 7, 2025 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for non-CommonMark extensions in mdast_util_to_markdown
2 participants